// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://gpzx.cei.cn/*
// @icon         
// @require      https://unpkg.com/ajax-hook/dist/ajaxhook.min.js
// @grant        none
// ==/UserScript==


(function () {
    var courseList=[];
    proxyProgress();
    function proxyProgress() {
        console.log("开始监听咯");
        ah.proxy({
            onRequest: (config, handler) => {
                handler.next(config);
            },
            onError: (err, handler) => {
                handler.next(err);
            },
            onResponse: (response, handler) => {
                console.log(response);
                if (response && response.config && response.config.url && response.config.url.includes("trainingcourse/queryCoursewarelist")) {
                    console.log("被拦截咯")
                    //课程列表
                    let result = JSON.parse(response.response);
                    console.log(result);
                    let cwlist = result.cwlist;
                    if (!cwlist || cwlist.length === 0) {
                        console.error("获取课程进度失败")
                    }
                    courseList.push(cwlist);
                    ah.unProxy();
                }
                handler.next(response);
            }
        });
    }

    // Your code here...
})();
